<?php
// @formatter:off
/**
 * @file c.menu.php
 *
 * @author Alejandro Dario Simi
 * @date $Date: 2013-06-16 23:56:49 +0000 (Sun, 16 Jun 2013) $
 *
 * $Id: c.menu.php 73 2013-06-16 23:56:49Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/tags/wcomix-1.0.0.1/themes/mdefault/controlers/contents/c.menu.php $
 */
// @formatter:on

global $wcDefaults;
global $wcSession;

$wcThemeAssigns['ACTIONCONTENT'] = "/generics/list-view.html";
$wcThemeAssigns["MenuLists"] = array();

if($wcGroup) {
	$groupId = $wcGroup->id;

	$wcThemeAssigns["PATH"] = "Menu";

	$menuList = array();

	//
	// Current Group
	$wcThemeAssigns["MenuLists"][] = array(
		"prefix" => "Current Group",
		"list" => array( array(
				"name" => $wcGroup->name(),
				"title" => $wcGroup->name(),
				"icon" => "{$this->uri()}/icons/group-icon.png",
				"url" => "?action=".WC_ACTION_MENU."&group={$groupId}"
			))
	);

	//
	// Menu
	if($wcDefaults["mobile-action"] != $wcAction) {
		$aux = array(
			"name" => "Home",
			"title" => "Home",
			"icon" => "{$this->uri()}/icons/home-icon.png",
			"url" => "?group={$groupId}"
		);
		$menuList[] = $aux;
	}
	if($wcProfile->allowedTo(WC_PERM_COLLECTION_LIST)) {
		$aux = array(
			"name" => "Collections",
			"title" => "Collections",
			"icon" => "{$this->uri()}/icons/collections-icon.png",
			"url" => "?action=".WC_ACTION_COLLECTION_LIST."&group={$groupId}"
		);
		$menuList[] = $aux;
	}
	if($wcProfile->allowedTo(WC_PERM_TAG_LIST)) {
		$aux = array(
			"name" => "Tags",
			"title" => "Tags",
			"icon" => "{$this->uri()}/icons/tags-icon.png",
			"url" => "?action=".WC_ACTION_TAG_LIST."&group={$groupId}"
		);
		$menuList[] = $aux;
	}
	if($wcProfile->allowedTo(WC_PERM_SPECIAL_SEARCH)) {
		$aux = array(
			"name" => "Search",
			"title" => "Search",
			"icon" => "{$this->uri()}/icons/search-icon.png",
			"url" => "?action=".WC_ACTION_SEARCH."&group={$groupId}"
		);
		$menuList[] = $aux;
	}
	if(!$wcDefaults["no-credits"] && $wcProfile->allowedTo(WC_PERM_SPECIAL_CREDIT)) {
		$aux = array(
			"name" => "Credits",
			"title" => "Credits",
			"icon" => "{$this->uri()}/icons/wcomix.png",
			"url" => "?action=".WC_ACTION_CREDITS."&group={$groupId}"
		);
		$menuList[] = $aux;
	}
	if(!$wcSession->isLogged() && $wcProfile->allowedTo(WC_PERM_USER_LOGIN)) {
		$aux = array(
			"name" => "Log In",
			"title" => "Log In",
			"icon" => "{$this->uri()}/icons/user-icon.png",
			"url" => "?action=".WC_ACTION_LOG_IN."&group={$groupId}"
		);
		$menuList[] = $aux;
	} elseif($wcProfile->allowedTo(WC_PERM_USER_LOGOUT)) {
		$aux = array(
			"name" => "Log Out",
			"title" => "Log Out",
			"icon" => "{$this->uri()}/icons/no-user-icon.png",
			"action" => "LogOut('".WC_SERVICE_LOG_OUT."')"
		);
		$menuList[] = $aux;
	}
	$aux = array(
		"name" => "Leave Mobile",
		"title" => "Leave mobile mode",
		"icon" => "{$this->uri()}/icons/mobile-icon.png",
		"action" => "SetMobile('".WC_SERVICE_MOBILE."', false)"
	);
	$menuList[] = $aux;

	$wcThemeAssigns["MenuLists"][] = array(
		"prefix" => "Menu",
		"list" => $menuList
	);

	//
	// Available Groups
	$menuList = array();
	foreach($wcGroupsHolder->groups() as $group) {
		if($group->id != $groupId && $wcProfile->grantedGroup($group)) {
			$menuList[] = array(
				"name" => $group->name(),
				"title" => $group->name(),
				"icon" => "{$this->uri()}/icons/group-icon.png",
				"url" => "?action=".WC_ACTION_MENU."&group={$group->id()}"
			);
		}
	}
	if(count($menuList)) {
		$wcThemeAssigns["MenuLists"][] = array(
			"prefix" => "Available Groups",
			"list" => $menuList
		);
	}
}
?>